package com.ngmaster.apiserver.util;

/**
 * 随机字符串
 *
 */
public class RandomString {
	/**
	 * 随机字符串的来源
	 */
	private static final String Sources = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
	
	/**
	 * 生成字符串
	 * @param length
	 * @return
	 */
	public static String generate(int length) {
		StringBuilder result = new StringBuilder();
		for(int index = 0; index < length; ++index) {
			result.append(Sources.charAt(RandomUtil.nextInt(Sources.length())));
		}
		
		return result.toString();
	}
}
